<?php namespace Home\Controller;
use Hdphp\Controller\Controller;
/**
 * 地址管理控制器
 */
class AddressController extends Controller
{
	protected $db;
	public function __init()
	{
		$this->db = new \Common\Model\Address;
	}
	/**
	 * 添加
	 */
	public function store()
	{
		if(IS_POST)
		{
			if(!$this->db->store())
			{
				$this->error($this->db->getError());
			}else{
				go('Order/index');
			}
		}
	}
	/**
	 * 修改
	 */
	public function edit()
	{
		if(IS_POST)
		{
			if(!$this->db->edit())
			{
				$this->error($this->db->getError());
			}else{
				go('Order/index');
			}
		}		
	}
	public function getAjax()
	{
		if(IS_AJAX)
		{
			$aid = $_POST['aid'];
			$oldadData = $this->db->where('aid',$aid)->first();
			echo json_encode($oldadData);
		}
	}
}
